package com.qiyu.mall.user.provider.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.qiyu.mall.user.provider.entity.AccountPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @author linhao
 * @date 2019/12/14
 * @Version V1.0
 */
@Mapper
public interface AccountDao extends BaseMapper<AccountPO> {

    @Select("select * from t_account where account_id=#{accountId}")
    AccountPO selectOneByAccountId(@Param("accountId") Integer accountId);


    @Select("select * from t_account where open_id=#{openid}")
    AccountPO selectOneByOpenId(@Param("openid") String openid);

    @Update("update t_account set last_login_time=NOW()  where open_id=#{openId}")
    Integer updateLoginTime(@Param("openId")String openId);

    @Update("update t_account set wx_avatar_url = #{wxAvatarUrl},wx_nick_name=#{wxNickName} where account_id=#{accountId}")
    Integer updateWxInfo(@Param("wxAvatarUrl")String wxAvatarUrl,@Param("wxNickName")String wxNickName,@Param("accountId")Integer accountId);


    @Update("update t_account set tel = #{tel} where account_id=#{accountId}")
    Integer updatePhoneNumber(@Param("accountId")Integer accountId,@Param("tel")String tel);
}
